package com.bwie.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bwie.pojo.TbProdInfo;
import com.bwie.service.TbProdInfoService;
import com.bwie.mapper.TbProdInfoMapper;
import com.bwie.utils.Result;
import com.bwie.vo.PageInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author 28242
* @description 针对表【tb_prod_info(商品详情表)】的数据库操作Service实现
* @createDate 2025-05-29 16:50:18
*/
@Service
public class TbProdInfoServiceImpl extends ServiceImpl<TbProdInfoMapper, TbProdInfo>
    implements TbProdInfoService{

    @Autowired
    TbProdInfoMapper tbProdInfoMapper;
    @Override
    public Result getProdInfoList(PageInfoVo pageInfoVo) {

        Page<TbProdInfo> page = new Page<>(pageInfoVo.getPageNum(),pageInfoVo.getPageSize());

//        QueryWrapper<TbProdInfo> wrapper = new QueryWrapper<>();
//
//        wrapper.lambda().eq(TbProdInfo::getProdId,pageInfoVo.getTypeId());
//        wrapper.lambda().orderByDesc(TbProdInfo::getInfoId);

        Page<TbProdInfo> tbProdInfoPage = tbProdInfoMapper.getProdInfoList(page, pageInfoVo.getTypeId());

        for (TbProdInfo record : tbProdInfoPage.getRecords()) {
            record.setBuyNum(1);
        }

        return Result.ok().setData(tbProdInfoPage);
    }
}




